/* GUI CONVERTED from rwbdncal.p (converter v1.75) Sat Aug 12 23:17:10 2000 */
/* rwbdncal.p - OPERATION BURDEN CALCULATION PROGRAM                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*G1DD*/ /*V8:ConvertMode=Maintenance                                   */
/* REVISION: 7.3      LAST MODIFIED: 11/15/95   BY: bcm *G1DD*          */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb          */


/*!


   rwbdncal.p is the calculation program for burden for a routing operation.
          This program calculates several types of operation burden cost
          based upon the services specified (burden-type &
          accumulate-burden).  All operation burden calculations should
          use this program to insure consistency.
*/

/*!
   Input Parameters:

   burden-type         = burden cost type to be calculated
             "TOTAL" = all components of burden
             "LABOR" = labor burden (setup & run)
             "MACHINE" = machine burden (setup & run)
             "SETUP" = setup burden (labor & machine)
             "RUN" = run burden (labor & machine)

   accumulate-burden   = determines whether the calculated burden is to be
             added to the value of op-burden.  "NO" causes the
             output value to be reset to 0 before calculating
             the specified burden cost.
   burden-percent      = work center burden percent 0.00-1.00
   burden-rate         = work center burden rate
   labor-rate          = work center labor rate
   machine-burden-rate = work center machine burden rate
   machines            = routing machines in operation
   ord-quantity        = order quantity
   run-time            = routing run time
   setup-rate          = routing setup rate
   setup-time          = routing setup time
   yield-percent       = item yield percent

   Input-Output Parameter:
   op-burden           = calculated burden cost.

*/

/*!

   Usage:  This program adds the calculated operation burden to a
   total burden variable/field.  This calculation is used for routing
   cost roll-up routines. Use the following form (in fact, you can
   copy/paste it) in programs calculating total burden.  An explanation of
   each of the burden cost calculations is provided below.

          /*! CALCULATE OPERATION BURDEN USING THE STANDARD           *
           *  EQUATION.                                               */
          {gprun.i ""rwbdncal.p""
               "( input burden-type          /* BURDEN COST TYPE */,
                  input accumulate-burden   /* ACCUMULATE TOTAL? */,
                  input burden-percent         /* BURDEN PERCENT */,
                  input burden-rate               /* BURDEN RATE */,
                  input labor-rate                 /* LABOR RATE */,
                  input machine-burden-rate /*MACHINE BURDEN RATE*/,
                  input machines                /* MACHINES USED */,
                  input ord-quantity           /* ORDER QUANTITY */,
                  input run-time                /* UNIT RUN TIME */,
                  input setup-rate                 /* SETUP RATE */,
                  input setup-time                 /* SETUP TIME */,
                  input yield-percent           /* YIELD PERCENT */,
                  input-output op-burden           /* BURDEN COST */
                )"
          }

          TOTAL BURDEN
          Below is an example of how to call for total burden:

          /*! CALCULATE TOTAL OPERATION BURDEN USING THE STANDARD     *
           *  EQUATION.                                               */
          {gprun.i ""rwbdncal.p""
               "( input 'TOTAL'              /* BURDEN COST TYPE */,
                  input yes                 /* ACCUMULATE TOTAL? */,
                  input (wc_bdn_pc * 0.01)     /* BURDEN PERCENT */,
                  input wc_bdn_rate               /* BURDEN RATE */,
                  input wc_lbr_rate                /* LABOR RATE */,
                  input wc_mch_bdn        /* MACHINE BURDEN RATE */,
                  input ro_mch_op               /* MACHINES USED */,
                  input ord_qty                /* ORDER QUANTITY */,
                  input ro_run                  /* UNIT RUN TIME */,
                  input wc_setup_rte               /* SETUP RATE */,
                  input ro_setup                   /* SETUP TIME */,
                  input (part_yield * 0.01)     /* YIELD PERCENT */,
                  input-output total-burden       /* BURDEN COST */
                )"
          }

          SETUP BURDEN
          Below is an example of how to call for setup burden. Notice
          how we can use 0 for unneeded values, although it does not
          hurt to specify valid field or variable names if they are
          available in the calling program:

          /*! CALCULATE OPERATION SETUP BURDEN USING THE STANDARD     *
           *  EQUATION.                                               */
          {gprun.i ""rwbdncal.p""
               "( input 'SETUP'              /* BURDEN COST TYPE */,
                  input yes                 /* ACCUMULATE TOTAL? */,
                  input (wc_bdn_pc * 0.01)     /* BURDEN PERCENT */,
                  input wc_bdn_rate               /* BURDEN RATE */,
      ----> NOT NEEDED    input 0                          /* LABOR RATE */,
                  input wc_mch_bdn        /* MACHINE BURDEN RATE */,
                  input ro_mch_op               /* MACHINES USED */,
                  input ord_qty                /* ORDER QUANTITY */,
      ----> NOT NEEDED    input 0                       /* UNIT RUN TIME */,
                  input wc_setup_rte               /* SETUP RATE */,
                  input ro_setup                   /* SETUP TIME */,
                  input (part_yield * 0.01)     /* YIELD PERCENT */,
                  input-output total-burden       /* BURDEN COST */
                )"
          }

          RUN BURDEN
          Below is an example of how to call for run burden. Notice
          how we can use 0 for unneeded values, although it does not
          hurt to specify valid field or variable names if they are
          available in the calling program:

          /*! CALCULATE OPERATION RUN BURDEN USING THE STANDARD       *
           *  EQUATION.                                               */
          {gprun.i ""rwbdncal.p""
               "( input 'RUN'                /* BURDEN COST TYPE */,
                  input yes                 /* ACCUMULATE TOTAL? */,
                  input (wc_bdn_pc * 0.01)     /* BURDEN PERCENT */,
                  input wc_bdn_rate               /* BURDEN RATE */,
                  input wc_lbr_rate                /* LABOR RATE */,
                  input wc_mch_bdn        /* MACHINE BURDEN RATE */,
      ----> NOT NEEDED    input 0                       /* MACHINES USED */,
      ----> NOT NEEDED    input 1                      /* ORDER QUANTITY */,
                  input ro_run                  /* UNIT RUN TIME */,
      ----> NOT NEEDED    input 0                          /* SETUP RATE */,
      ----> NOT NEEDED    input 0                          /* SETUP TIME */,
                  input (part_yield * 0.01)     /* YIELD PERCENT */,
                  input-output total-burden       /* BURDEN COST */
                )"
          }

          LABOR BURDEN
          Below is an example of how to call for labor burden. Notice
          how we can use 0 for unneeded values, although it does not
          hurt to specify valid field or variable names if they are
          available in the calling program:

          /*! CALCULATE OPERATION LABOR BURDEN USING THE STANDARD     *
           *  EQUATION.                                               */
          {gprun.i ""rwbdncal.p""
               "( input 'LABOR'              /* BURDEN COST TYPE */,
                  input yes                 /* ACCUMULATE TOTAL? */,
                  input (wc_bdn_pc * 0.01)     /* BURDEN PERCENT */,
                  input wc_bdn_rate               /* BURDEN RATE */,
                  input wc_lbr_rate                /* LABOR RATE */,
      ----> NOT NEEDED    input 0                 /* MACHINE BURDEN RATE */,
      ----> NOT NEEDED    input 0                       /* MACHINES USED */,
                  input ord_qty                /* ORDER QUANTITY */,
                  input ro_run                  /* UNIT RUN TIME */,
                  input wc_setup_rte               /* SETUP RATE */,
                  input ro_setup                   /* SETUP TIME */,
                  input (part_yield * 0.01)     /* YIELD PERCENT */,
                  input-output total-burden       /* BURDEN COST */
                )"
          }

          MACHINE BURDEN
          Below is an example of how to call for machine burden. Notice
          how we can use 0 for unneeded values, although it does not
          hurt to specify valid field or variable names if they are
          available in the calling program:

          /*! CALCULATE OPERATION MACHINE BURDEN USING THE STANDARD   *
           *  EQUATION.                                               */
          {gprun.i ""rwbdncal.p""
               "( input 'MACHINE'            /* BURDEN COST TYPE */,
                  input yes                 /* ACCUMULATE TOTAL? */,
      ----> NOT NEEDED    input 0                      /* BURDEN PERCENT */,
      ----> NOT NEEDED    input 0                         /* BURDEN RATE */,
      ----> NOT NEEDED    input 0                          /* LABOR RATE */,
                  input wc_mch_bdn        /* MACHINE BURDEN RATE */,
                  input ro_mch_op               /* MACHINES USED */,
                  input ord_qty                /* ORDER QUANTITY */,
                  input ro_run                  /* UNIT RUN TIME */,
      ----> NOT NEEDED    input 0                          /* SETUP RATE */,
                  input ro_setup                   /* SETUP TIME */,
                  input (part_yield * 0.01)     /* YIELD PERCENT */,
                  input-output total-burden       /* BURDEN COST */
                )"
          }

   MFG/PRO uses the following equations for calculating burden:

--------------------------------------------------------------------------------

   SETUP Burden =
      (( routing setup time / order quantity ) *
       ( work center setup rate * work center burden percent ) +
     work center burden rate +
       ( work center machine burden rate * routing machines used )
      ) * item yield percentage

--------------------------------------------------------------------------------

   RUN Burden =
      ( routing run time *
       ( work center labor rate * work center burden percent +
     work center burden rate + work center machine burden rate
       )
      ) * item yield percentage

--------------------------------------------------------------------------------

   SETUP LABOR Burden =
      (( routing setup time / order quantity ) *
       ( work center setup rate * work center burden percent ) +
     work center burden rate
      ) * item yield percentage

   RUN LABOR Burden =
      ( routing run time *
       ( work center labor rate * work center burden percent +
     work center burden rate
       )
      ) * item yield percentage


   LABOR Burden = Setup Labor Burden + Run Labor Burden

      or

      Labor Burden =  Labor Burden +
      (
        (
          ( routing setup time / order quantity ) *
          ( work center setup rate * work center burden percent) +
        work center burden rate
          )
        ) +
        ( routing run time *
          ( work centerlabor rate * work center burden percent +
        work center burden rate + work center machine burden rate
          )
        )
      ) * item yield percentage

--------------------------------------------------------------------------------

   MACHINE SETUP Burden =
      (
        ( routing setup time / order quantity ) *
        ( work center machine burden rate * routing machines used )
      ) * item yield percentage

   MACHINE RUN Burden =
      ( routing run time * work center machine burden rate
      ) * item yield percentage

   MACHINE Burden =  Machine Setup Burden + Machine Run Burden

      or

   MACHINE Burden =  Machine Burden +
      (
        (
          ( routing setup time / order quantity ) *
          ( work center machine burden rate * routing machines used )
        ) +
        ( routing run time * work center machine burden rate )
      ) * item yield percentage

--------------------------------------------------------------------------------

   Total burden consists of the sum of setup and run burden multiplied by
   the yield percentage.  Total burden can also be viewed as being the sum
   of labor and machine burden multiplied by the yield percentage.

   TOTAL Burden = Setup Burden + Run Burden

      or

   TOTAL Burden = Labor Burden + Machine Burden

      or

      Total Burden =  Total Burden +
      (
        (
          ( routing setup time / order quantity ) *
          ( work center setup rate * work center burden percent) +
        work center burden rate +
        work center machine burden rate * routing machines used
          )
        ) +
        ( routing run time *
          ( work center labor rate * work center burden percent +
        work center burden rate + work center machine burden rate
          )
        )
      ) * item yield percentage

   The actual equations below should match those above.

*/

     {mfdeclre.i}
     define input parameter burden-type as character.

     define input parameter accumulate-burden   as logical.
     define input parameter burden-percent      like wc_bdn_pc.
     define input parameter burden-rate         like wc_bdn_rate.
     define input parameter labor-rate          like wc_lbr_rate.
     define input parameter machine-burden-rate like wc_mch_bdn.
     define input parameter machines            like ro_mch_op.
     define input parameter ord-quantity        as decimal.
     define input parameter run-time            like ro_run.
     define input parameter setup-rate          like wc_setup_rte.
     define input parameter setup-time          like ro_setup.
     define input parameter yield-percent       like ro_yield.

     define input-output parameter op-burden    as decimal.

     /*! RESET OUTPUT PARAMETER IF WE ARE NOT ACCUMULATING TOTALS */
     if not accumulate-burden then
        op-burden = 0.

     /*! PREVENT DIVIDE-BY-ZERO ERRORS */
     if ord-quantity = 0 then ord-quantity = 1.

     if burden-type = "TOTAL" then do:
        op-burden = op-burden +
            (
              (
                ( setup-time *
                  ( setup-rate * burden-percent +
                burden-rate +
                machine-burden-rate * machines
                  )
                ) / ord-quantity
              ) +
              ( run-time *
                ( labor-rate * burden-percent +
                   burden-rate + machine-burden-rate
                )
              )
            ) * yield-percent.
     end.
     else if burden-type = "SETUP" then do:
        op-burden = op-burden +
            (
              ( setup-time *
                ( setup-rate * burden-percent +
                  burden-rate +
                  machine-burden-rate * machines
                )
              ) / ord-quantity
            ) * yield-percent.
     end.
     else if burden-type = "RUN" then do:
        op-burden = op-burden +
            ( run-time *
              ( labor-rate * burden-percent +
                 burden-rate + machine-burden-rate
              )
            ) * yield-percent.
     end.
     else if burden-type = "LABOR" then do:
        op-burden = op-burden +
            (
              (
                ( setup-time *
                  ( setup-rate * burden-percent +
                burden-rate
                  )
                ) / ord-quantity
              ) +
              ( run-time *
                ( labor-rate * burden-percent +
                   burden-rate
                )
              )
            ) * yield-percent.
     end.
     else if burden-type = "MACHINE" then do:
        op-burden = op-burden +
            (
              (
                ( setup-time *
                  machine-burden-rate * machines
                ) / ord-quantity
              ) +
              ( run-time * machine-burden-rate
              )
            ) * yield-percent.
     end.
